package com.wy.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.wy.ssm.domain.Order;
import com.wy.ssm.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Author: wy
 * @Date:2019/9/4 17:25
 */
@Controller
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @RequestMapping("/findAll")
    public String findAll(@RequestParam(value = "pageNum",required = false,defaultValue = "1")Integer pageNum,
                        @RequestParam(value = "pageSize",required = false,defaultValue = "5")Integer pageSize,
                          @RequestParam(value = "orderNum",required = false,defaultValue = "") String orderNum, Model model)throws Exception{
          List<Order> orderList = orderService.findAll(pageNum, pageSize, orderNum);
        System.out.println(orderList);
        PageInfo<Order> pageInfo=new PageInfo<>(orderList);

        model.addAttribute("pageInfo",pageInfo);
        return "orders-list";
    }
}
